package com.example.javasample.controller;

import com.example.javasample.domain.BlogDO;
import com.example.javasample.service.IBlogService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * BlogController
 *
 * @author Kylin
 */
@Tag(name = "博客")
@RestController
@RequestMapping("/blog")
public class BlogController {

    @Autowired
    private IBlogService blogService;

    @ApiOperationSupport(order = 1)
    @Operation(summary = "列表", description = "")
    @GetMapping(value = "/list")
    public List<BlogDO> list(@ParameterObject BlogDO blog) {
        return blogService.list(blog);
    }

    @ApiOperationSupport(order = 2)
    @Operation(summary = "详情", description = "")
    @GetMapping("/detail/{blogId}")
    public BlogDO detail(@PathVariable Long blogId) {
        return blogService.detail(blogId);
    }

    @ApiOperationSupport(order = 3)
    @Operation(summary = "批量新增", description = "")
    @PostMapping("/batchAdd")
    public int batchAdd(@RequestBody List<BlogDO> blogList) {
        return blogService.batchAdd(blogList);
    }

}
